import {
  axiosTokenProxy,
  mockAxiosDecorator
} from "../utils/reqTools";
import moment from 'moment';
const axios = require('axios');
const MockAdapter = require('axios-mock-adapter');
const normalAxios = axios.create();
const mockAxios = axios.create();

// mock 数据
const mock = new MockAdapter(mockAxios);


mock.onGet('/findPage').reply((config) => {
  return new Promise(function (resolve, reject) {
    axiosTokenProxy.get('/api/QrUserInfo/findPage', config).then((res) => {
      res.data = res.data || [];
      resolve([200, res]);
    }).catch((err) => {
      reject(err);
    });
  });
});

mock.onPost('/buy').reply((config) => {
  return new Promise(function (resolve, reject) {
    axiosTokenProxy.post('/api/QrUserInfo', config).then((res) => {
      resolve([200, res]);
    }).catch((err) => {
      reject(err);
    });
  });
});
mock.onPut('/mark').reply((config) => {
  return new Promise(function (resolve, reject) {
    axiosTokenProxy.put('/api/QrUserInfo/updateState', config).then((res) => {
      resolve([200, res]);
    }).catch((err) => {
      reject(err);
    });
  });
});

export default mockAxiosDecorator(mockAxios);
